<template>
	<view class="page">
		<view class="my-card">
			<view class="text-white">
				<text v-if="!hasTask" class="zwrw">暂无任务</text>
				<view v-else>
					<view class="title_body">
						<text class="title">
							{{task.name}}
						</text>
						<button @click="see_detail(task.ucId)" class="cu-btn round my-btn">查看</button>
					</view>
					<view class="content">
						<text>火情地址：{{task.name}}</text>
						<text>火情确认人员：{{task.name}}</text>
						<text>确认时间：{{task.name}}</text>
						<text>企业负责人：{{task.name}}</text>
						<text>企业负责人电话：{{task.name}}</text>
					</view>
				</view>
			</view>
		</view>

		<view class="u-tools">
			<view>
				<text class="tools-title">任务管理</text>
				<view class="bg-2" style="" @click="jdjc">
					<text class="tools-desc">监督检查</text>
				</view>
			</view>
			<view>
				<text class="tools-title">主体管理</text>
				<view style="" class="bg-3" @click="qyxx">
					<text class="tools-desc">企业信息</text>
				</view>
			</view>
		</view>

		<view class="utools">
			<text class="utools-title">预防演练</text>
			<view class="uk">
				<view class="last_mk bg-4" style="" @click="hqxx">
					<view class="uk_title">
						<text>火情信息</text>
					</view>
				</view>
				<view class="last_mk bg-5" style="" @click="xfyh">
					<view class="uk_title">
						<text>消防隐患</text>
					</view>
				</view>
				<view class="last_mk bg-6" style="" @click="wbgd">
					<view class="uk_title">
						<text>维保工单</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		isDateBetween,
		isEmpty
	} from '@/common/formatDate.js'
	export default {
		created() {
			console.info("ahome create")

			this.getTask()

			uni.$on('refreshPage', function() {
				this.getTask()
			})
		},

		onShow() {
			let s1 = "2022-03-29 10:30:00"
			let start = "2022-03-29 11:00:00"
			let end = "2022-03-29 11:30:00"
			let flag = isDateBetween(s1, start, end)
			console.info("ahome onShow")

		},
		data() {
			return {
				hasTask: false,
				task: ''
			}
		},
		methods: {

			getTask() {
				let that = this
				let params = {
					"pageNum": 1,
					"pageSize": 1,
					"status": 1
				}
				// 请求数据
				let app = getApp()
				app.globalData.request({
					url: 'wx/taskmanage/getMyTaskEnterprisePage',
					data: {
						...params
					}
				}).then(function(res) {
					if (res.data.data.list.length > 0) {
						that.hasTask = true
						that.task = res.data.data.list[0]
					} else {
						that.hasTask = false
					}

				}).catch(function(e) {
					that.hasTask = false
				})
			},
			jdjc() {
				uni.navigateTo({
					url: '/jgbm/jcrw/jcrw'
				})
			},
			qyxx() {
				uni.navigateTo({
					url: '/jgbm/qyxx/qyxx'
				})
			},
			hqxx() {
				uni.navigateTo({
					url: '/jgbm/hqxx/hqxx'
				})
			},
			xfyh() {
				uni.navigateTo({
					url: '/jgbm/xfyh/xfyh'
				})
			},
			wbgd() {
				uni.navigateTo({
					url: '/jgbm/wbgd/wbgd'
				})
			},
			see_detail(ucId) {
				uni.navigateTo({
					url: '/jgbm/jcxq/jcxq?ucId=' + ucId
				})
			}

		}
	}
</script>

<style scoped>
	.page {
		margin: 0 24rpx;
		margin-top: 39rpx;
		height: 400px;
	}

	.my-card {
		height: 320rpx;
		border-radius: 25upx;
		padding: 24upx 50upx;
		background: url('https://tva1.sinaimg.cn/large/005Tv2WXgy1h0l68cxv8sj309r04gaak.jpg') no-repeat;
		background-size: cover;
	}

	.title_body {
		font-family: PingFangSC-Medium;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: left;
		margin: 20upx 10upx;
	}

	.my-btn {
		float: right;
		font-size: 24rpx;
		color: #3013F7;
		height: 50rpx;
	}

	.content {
		font-family: PingFangSC-Medium;
		font-size: 24rpx;
		color: #FFFFFF;
		letter-spacing: 0.39px;
		text-align: left;
		line-height: 14rpx;
		display: flex;
		flex-direction: column;
	}

	.content text {
		margin: 6px 0;
	}

	.u-tools {
		display: flex;
		flex-direction: row;
		margin-top: 40upx;
	}

	.tools-title {
		font-size: 32rpx;
		color: #777777;
		font-weight: 600;
	}

	.tools-desc {
		font-size: 28rpx;
		color: #333333;
		font-weight: 600;
		height: 160rpx;
		width: 100%;
		display: inline-block;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-left: 60rpx;
	}

	.u-tools view {
		flex: 1;

	}

	.utools {
		margin-top: 40upx;
	}

	.utools-title {
		font-size: 32rpx;
		color: #777777;
		font-weight: 600;
	}

	.uk {
		display: flex;
		justify-content: space-between;
		flex-direction: row;
		margin-top: 20upx;
	}

	.uk view {
		flex: 1;
		height: 105upx;
		border-radius: 8px;
	}

	.uk .last_mk {
		height: 280rpx;
		border-radius: 8px;
	}

	.uk text {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100%;
		padding-left: 90rpx;
		font-size: 28rpx;
		color: #FFFFFFFF;
		font-weight: 600;
	}

	.uk .last_mk text {
		height: 220rpx;
		color: #FFFFFFFF;
		display: flex;
		padding-left: 0;
		flex-direction: row;
		align-items: flex-end;
	}

	.bg-2 {
		height: 180upx;
		background: url(~@/static/home/aHome/icon_jiandujiancha.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-3 {
		height: 180upx;
		background: url('@/static/home/aHome/icon_qiyexinxi.png') no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-4 {
		background: url(@/static/home/aHome/icon_huoqingxinxi.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-5 {
		background: url(@/static/home/aHome/icon_xiaofangyinhuan.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-6 {
		background: url(@/static/home/aHome/icon_weibaogongdan.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.zwrw {
		font-size: 48rpx;
	}
</style>
